/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DBManager;

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 * This class provide connection with database which placed on removed or local server dsac
 * @author Иван
 */
public class ConnectManager {

    private String url;
    private String user;
    private String password;
    public Connection connection = null;

    public ConnectManager() {
        this.url = "jdbc:mysql://localhost/teamhelperDB";
        this.user = "admin";
        this.password = "123123";
    }

    public ConnectManager(String url, String name, String password) {
        this.url = url;
        this.user = name;
        this.password = password;
    }

    public void EstablishAccess() {
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            connection = DriverManager.getConnection(url, user, password);

        } catch (ClassNotFoundException e) {
            JOptionPane.showMessageDialog(null, "Error connecting JDBC Driver!");

        } catch (IllegalAccessException e) {
            JOptionPane.showMessageDialog(null, "Error connecting JDBC Driver!");

        } catch (InstantiationException e) {
            JOptionPane.showMessageDialog(null, "Error connecting JDBC Driver");

        } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, "Error database access! Possible some parameter entered not correct! ");
             JOptionPane.showMessageDialog(null, "Error database access! Possible some parameter entered not correct! ");

        }



    }
}
